<template>
  <div class="app-container">
    <el-table :data="list" v-loading.body="listLoading" element-loading-text="Loading" border fit highlight-current-row
              style="width: 100%">
      <el-table-column align="center" label='序号' width="52">
        <template slot-scope="scope">
          {{scope.$index + 1}}
        </template>
      </el-table-column>
      <el-table-column align="center" prop="createTime" label="登录时间">
        <template slot-scope="scope">
          <span>{{scope.row.createTime | dateTimeFilter}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="用户" prop="username"/>
      <el-table-column align="center" label="状态" prop="name"/>
    </el-table>
    <div class="pagination-container">
      <el-pagination background @size-change="handleSizeChange"
                     @current-change="handleCurrentChange"
                     :current-page="listQuery.page"
                     :page-sizes="[10,20,30,50]"
                     :page-size="listQuery.size"
                     layout="total, sizes, prev, pager, next, jumper"
                     :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
  import { parseTime } from '@/utils'
  import { page } from '@/api/sys/connSysAuthApi'

  export default {
    data() {
      return {
        module: 'log',
        list: null,
        info: null,
        ids: null,
        listLoading: true,
        total: 0,
        listQuery: {
          page: 1,
          size: 10,
          keyword: undefined
        }
      }
    },
    filters: {
      dateTimeFilter(time) {
        return parseTime(time)
      }
    },
    created() {
      this.page()
    },
    methods: {
      page() {
        this.listLoading = true
        page(this.module, this.listQuery).then(response => {
          this.list = response.data.content
          this.total = response.data.total
          this.listLoading = false
        })
      },
      handleFilter() {
        this.listQuery.page = 1
        this.page()
      },
      handleSizeChange(val) {
        this.listQuery.size = val
        this.page()
      },
      handleCurrentChange(val) {
        this.listQuery.page = val
        this.page()
      }
    }
  }
</script>
